"use client"
import React , { useEffect, useState }from 'react'
import { Input, Button  } from 'antd';
import { SearchOutlined } from '@ant-design/icons';
import { request } from '@/lib/request';

const page = () => {
    // 股票数据和开始时间存储
    const [startData, setStartData] = useState('111');
    const [sharesCode, setSharesCode] = useState('');

    // 处理用户搜索股票数据图表
    const reloadCharts = async (obj) => {
      const response = await request.post('http://127.0.0.1:8000/getoneshares', obj);
      refreshIframes()
      // console.log(response);
    };
    const handleOk = () => {
      if (startData.trim() && sharesCode.trim()){
        reloadCharts({ startData, sharesCode });
      }
    };

    // 刷新iframe
    const refreshIframes = () => {
      document.getElementById('iframe1').contentWindow.location.reload();
    }
  return (
    <div>
      <div>
        默认显示为上一次可视化结果
      {/* <Input placeholder="开始时间:20240430" value={startData} onChange={(e) => setStartData(e.target.value)}/> */}
      <Input placeholder="股票编码:000004" value={sharesCode} onChange={(e) => setSharesCode(e.target.value)}/>
      <Button type="primary" icon={<SearchOutlined />} style={{width:"100%"}} onClick={handleOk}>
        查询
      </Button>
      </div>
      <iframe id="iframe1" src="/zoushi.html" title="bulinxian" width="100%" height="500px" />
    </div>
  )
}

export default page
